
public class ContinuousPerceptron {

	private double[] weightings;
	private double learningRate;
	
	public ContinuousPerceptron(double[] w, double c) {
		weightings = w;
		learningRate = c;
	}
		
	//size of input == size of weightings 
	public double calcOutput(double[] y) {
		//using the bipolar activation function
		// (1 - e^-v)/(1+e^-v)
		// v = input' * weightings 
		double sum = 0.00;
		int j = 0;
		for (double i : y) {
			sum += i * weightings[j];
			j++;
		}
		return (1 - Math.exp(-sum)) / (1 + Math.exp(-sum));
	}
	
	public void setWeights(double[] w) {
		weightings = w;
	}
	
	public double[] getWeightings() {
		return weightings;
	}

	/*	
	public void updateWeightings(double[] i, double z, double d) {
		double newWeights[] = new double[weightings.length];
		double dz = 0.5 * (1 - Math.pow(z, 2.00));
		int j = 0;
		for (double nw : newWeights) {
			nw = weightings[j] + (0.5*learningRate)*(d - z)*(dz)*i[j];
			weightings[j] = nw;
			//System.out.println("New weight["+j+"] is: " + nw);
			j++;
		}
	}
	
	public void test() {
		double w[] = new double[2];
		w[0] = 2.5;
		w[1] = 1.75;
		weightings = w;
		double i[] = new double[2];
		i[0] = 1.00;
		i[1] = 1.00;
		double desired = 1.00;
		double output = calcOutput(i);
		this.updateWeightings(i, output, desired);
		System.out.println("Out is: " + output);
	} */
}
